package com.laterem.rtc.config;

import com.laterem.rtc.interceptor.AuthInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @creator: alan wu
 * @dateTime: 2023/5/19 02:07
 * @desc:
 */
@Slf4j
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        AuthInterceptor authInterceptor = new AuthInterceptor();
        registry.addInterceptor(authInterceptor)
                .excludePathPatterns("/call/admin/login")
                .excludePathPatterns("/call/user/login")
                .excludePathPatterns("/api-doc")
                .excludePathPatterns("/account/**")
                .excludePathPatterns("/admin/login/**")
                .excludePathPatterns("/user/login/**")
                .excludePathPatterns("/js/**", "/css/**", "/images/**", "/lib/**","/fonts/**")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**","/v2/**", "/swagger-ui.html/**")
                .addPathPatterns("/**");
    }



    // 必须添加
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry)
    {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");}
    }

//    @Override
//    protected void addInterceptors(InterceptorRegistry registry) {
//        AuthInterceptor authInterceptor = new AuthInterceptor();
//        registry.addInterceptor(authInterceptor)
//                .excludePathPatterns("/error")
//                .excludePathPatterns("/api-doc")
//                .excludePathPatterns("/swagger-ui/**")
//                .excludePathPatterns("/user/login/**")
//                .addPathPatterns("/**");
//
//    }

